﻿/*Problem 5. Maximal increasing sequence

Write a program that finds the maximal increasing sequence in an array.
*/
using System;


namespace _05.MaximalIncreasingSequence
{
    class MaximalIncreasingSequence
    {
        static void Main()
        {
            Console.WriteLine("Enter array dimension");
            int arrayLength = int.Parse(Console.ReadLine());
            int[] arrayTest = new int[arrayLength];
            int counter = 1;
            int maxSequence = 1;
            int index = 0;
            int indexOfSequenceEnd = 0;
            for (int i = 0; i < arrayTest.Length; i++)
            {
                Console.WriteLine("Enter Number");
                arrayTest[i] = int.Parse(Console.ReadLine());
            }
            for (int i = 0; i < arrayTest.Length - 1; i++)
            {
                if (arrayTest[i] < arrayTest[i + 1])
                {
                    counter++;
                    index = i + 1;

                }
                else
                {
                    if (counter > maxSequence)
                    {
                        maxSequence = counter;
                        indexOfSequenceEnd = index;
                    }
                    counter = 1;
                }
            }
            if (counter > maxSequence)
            {
                maxSequence = counter;
                indexOfSequenceEnd = index;
            }
            for (int i = indexOfSequenceEnd - maxSequence + 1; i <= indexOfSequenceEnd; i++)
            {
                Console.Write("{0}, ", arrayTest[i]);
            }
        }
    }
}
